﻿@model EvincePayroll.Data.MenuTableData
@{
    ViewBag.Title = "_CreateMenu";
}
<script type="text/javascript">
    function ClereTextbox() {
        $('#element_1_1').val('');
        $('#element_2').val('');
        $('#element_3').val('');
        $('#element_4').val('');
        $('#chkstatus').val('');

    }
    $(document).ready(function () {
        $('#btnCancel').click(function () {
            ClereTextbox();
            return false;
        });
        $("#validate1").submit(function () {
            var flag = false;
            $('.required').each(function () {
                if ($(this).val() == '') {
                    if ($(this).prev().attr('class') != 'error') {
                        $(this).before('<span class="error"></span>');
                    }
                    $(this).css({
                        border: '1px solid red'
                    });
                    flag = true;
                } else {
                    if ($(this).prev().attr('class') == 'error') {
                        $(this).prev().remove();
                        $(this).removeAttr('style');
                    }
                }
            });
            if (flag != true) {
                var isChecked = $('#chkstatus').is(':checked');
                $.ajax({
                    type: "POST",
                    url: "/UserRole/CreateNewMenu?isActive=" + isChecked,
                    data: $(this).serialize(),
                    dataType: 'json',
                    success: function (result) {
                        var oTable2 = $('#MenuListTable').dataTable();
                        oTable2.fnDraw();
                        ClereTextbox();
                        return false;
                    }
                });

            }
            return false;
        });
    });
</script>

<form id="validate1" method="post" action="CreateNewMenu" title="Create Menu">
    <div class="grid_5">
        <div class="box round" >
            <h2>
                Add Menu</h2>
            <div class="block">
                <div id="chart1">
                    <div class="block">
                      <ul style="width: 95%; border: 1px solid gray;">
                                        <li id="li_1">
                                            <label class="description" for="element_1">
                                                Menu Name
                                            </label>
                                            <br />
                                            <span>
                                                @Html.TextBoxFor(m => m.MenuName, new { id = "element_1_1", @class = "element text required", maxlength = "255", size = "8", value = "" })
                                                     </span></li>
                                        <li id="li_2">
                                            <label class="description" for="element_2">
                                                URL
                                            </label>
                                            <br />
                                            <div>
                                                @Html.TextBoxFor(m => m.URL, new { id = "element_2", name = "element_2", @class = "element text medium required", type = "text", maxlength = "255", value = "" })
                                            </div>
                                            <br />
                                            <br />
                                        </li>
                                     
                                        <li id="li_3">
                                            <label class="description" for="element_3">
                                               Title
                                            </label>
                                            <br />
                                            <div>
                                                @Html.TextBoxFor(m => m.Title, new { id = "element_3", name = "element_3", @class = "element text medium required", type = "text", maxlength = "255", value = "" })
                                            </div>
                                            <br />
                                            <br />
                                        </li>
                                        <li id="li_5">
                                            <label class="description" for="element_5">
                                               Description
                                            </label>
                                            <br />
                                            <div>
                                                @Html.TextBoxFor(m => m.Description, new { id = "element_4", name = "element_3", @class = "element text medium", type = "text", maxlength = "255", value = "" })
                                            </div>
                                            </li>
                                            <li id="li_6">
                                            <label class="description" for="element_6">
                                                IsActive
                                            </label>
                                            <br />
                                            <div style="float:left; width:98%;">
                                            <input type="checkbox" id="chkstatus" name="chksatatus" />
                                           @*<textarea name="txtDescription" cols="30" rows="10" id="Editor1" style="width:100%;"></textarea>*@
                                            
                                            </div>
                                            <br />
                                            <br />
                                            <br />
                                        </li>
                                       
                                   
                                        <li id="li_13">
                                        
                                            
                                            <button class="btn btn-orange" id="add" runat="server">
                                    Add</button>
                                   @* <button class="btn btn-orange" id="update" runat="server">
                                    Update</button>*@
                                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                <button class="btn btn-orange" id="btnCancel">
                                    Cancel</button>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
                                        <br />
                                        </li>
                                       <br />
                                    </ul>
                                  
                    </div>
                    
                </div>
            </div>
        </div>
    </div>
</form>
    
